"
I am a RBBrowserEnvironment on a set of classes of a class hierarchy.

Example:

(RBBrowserEnvironment new) forClass:Morph protocols:{'printing'}.
"
Class {
	#name : 'RBClassHierarchyEnvironment',
	#superclass : 'RBBrowserEnvironmentWrapper',
	#instVars : [
		'class'
	],
	#category : 'Refactoring-Environment',
	#package : 'Refactoring-Environment'
}

{ #category : 'instance creation' }
RBClassHierarchyEnvironment class >> class: aClass [
	^ self
		onEnvironment: self default
		class: aClass
]

{ #category : 'accessing' }
RBClassHierarchyEnvironment class >> defaultName [
	^ 'Hier'
]

{ #category : 'instance creation' }
RBClassHierarchyEnvironment class >> onEnvironment: anEnvironment class: aClass [
	^ (self onEnvironment: anEnvironment)
		class: aClass;
		yourself
]

{ #category : 'comparing' }
RBClassHierarchyEnvironment >> = anotherEnvironment [

	self == anotherEnvironment 
		ifTrue: [ ^ true ].
	
	anotherEnvironment class = self class ifFalse: [ ^ false ].
	
	^ environment = anotherEnvironment environment and: [ class = anotherEnvironment hierarchyClass ]
]

{ #category : 'accessing' }
RBClassHierarchyEnvironment >> basisObjects [
	^ { class }
]

{ #category : 'accessing' }
RBClassHierarchyEnvironment >> class: aClass [
	class := aClass
]

{ #category : 'testing' }
RBClassHierarchyEnvironment >> definesClass: aClass [
	^ (aClass == class or:
		[ (class inheritsFrom: aClass) or:
			[ aClass inheritsFrom: class ] ]) and: [super definesClass: aClass]
]

{ #category : 'comparing' }
RBClassHierarchyEnvironment >> hash [

	^ super hash bitXor: class hash
]

{ #category : 'accessing' }
RBClassHierarchyEnvironment >> hierarchyClass [

	^ class
]

{ #category : 'testing' }
RBClassHierarchyEnvironment >> includesClass: aClass [
	^ (aClass == class or:
		[ (class inheritsFrom: aClass) or:
			[ aClass inheritsFrom: class ] ]) and: [super includesClass: aClass]
]

{ #category : 'printing' }
RBClassHierarchyEnvironment >> storeOn: aStream [
	aStream nextPut: $(.
	super storeOn: aStream.
	aStream nextPutAll: ' class: (('.
	class storeOn: aStream.
	aStream nextPutAll: ')))'
]
